<template>
  <div class="dialog">
    <div class="dialog-con num-container">
      <split-vertical title="数量详情"></split-vertical>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="购买数量" prop="purchaseNum">
          <el-input v-model="ruleForm.purchaseNum"></el-input>
        </el-form-item>
        <el-form-item label="出仓仓库">
          <el-select v-model="rowData.depotName" placeholder="请选择" size="medium" clearable disabled>
            <el-option
              v-for="item in depotList"
              :key="item.id"
              :label="item.depotName"
              :value="item.id+''">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item  style="margin-top:150px;">
          <el-button type="primary" @click="submitForm('ruleForm')" size="medium">提交</el-button>
          <el-button @click="cancelOper" size="medium">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
  import SplitVertical from "components/common/SplitVertical"

  export default {
    components: {
      SplitVertical
    },
    data() {
      return {
        depotList: [],
        ruleForm: {
          purchaseNum:''
        },
        rules: {
          purchaseNum: [
            { required: true, message: '请输入购买数量', trigger: 'change' },
          ],
        }
      }
    },
    props:{
      rowData:{
        type:Object,
        default:{}
      }
    },
    created(){
      this.getDopot()
    },
    methods: {
      submitForm(ruleForm) {
        this.$refs[ruleForm].validate((valid) => {
          if (valid) {
            this.submitNum()
          } else {
            return false;
          }
        });
      },
      submitNum(){
        this.ruleForm["supplyItemId"]=this.rowData.supplyItemId
        this.ruleForm["itemSkuName"]=this.rowData.itemSkuName
        this.ruleForm["itemCode"]=this.rowData.itemCode
        this.ruleForm['itemId']=this.rowData.itemId
        this.ruleForm['depotCode']=this.rowData.depotName
        this.$emit("submitData",this.ruleForm)
      },
      //获取仓库的select列表
      getDopot(){
        let success=data=>{
          if(data.code=="OK"){
            this.depotList=data.data
          }else{
            this.$message.error(data.msg)
          }
        }
        this.api.erpComplainDepotListAll({},success)
      },
      cancelOper() {
        this.$emit("submitData")
      },
    }
  }
</script>
<style lang="scss" scoped>
  .num-container {
    width: 400px;
    height: 350px;
    .el-input {
      width: 80%;
    }
    .el-select{
      width: 80%;
    }
  }
</style>
